import java.util.Arrays;

public class AdjustArryPlace {
    public static void main(String[] args) {
        int[] arry = {1, 2, 3, 4, 5, 6};
        System.out.println(Arrays.toString(arry));
        Adjustarry1(arry);

    }

 //用到了两个数组，引入了两个left和right下标去给arry2赋值arry1
    public static void Adjustarry1(int[] arry1) {
        int[] arry2 = new int[arry1.length];
        int left = 0;
        int right = arry1.length - 1;
        for (int i = 0; i < arry1.length; i++) {
            if (arry1[i] % 2 == 0) {
                arry2[right] = arry1[i];
                right--;
            } else {
                arry2[left] = arry1[i];
                left++;
            }


        }
        System.out.println(Arrays.toString(arry2));
    }

    public static void Adjustarry(int[] arry) {
        //在两个数组里还不会，先待定
        for (int i = 0; i < arry.length; i++) {
            for (int j = i + 1; j < arry.length; j++) {
                if (arry[i] % 2 != 0) {
                    arry[i] = arry[i];

                } else {
                    //int t=arry[i];
                    int t = arry[i];
                    arry[i] = arry[j];
                    arry[j] = t;
                    break;
                    //arry[j]=t;
                }
            }


        }
        System.out.println(Arrays.toString(arry));
       /* for (int i = 1; i <arry.length; i++) {
            if(arry[i]%2==0){
                int t=arry[i];
                arry[i]=arry[i]+1;

            }
            else arry[i]=arry[i];
        }
        System.out.println(Arrays.toString(arry));


        }*/


    }
}